<?php
class Application_Model_DbTable_wayBillItem extends Application_Model_DbTable_DomainObject{
	
	protected $_name = 'uuch_wayitem';
	
	public function getMapper(){
		return array('id','storeItemId','wayId');
	}
        
        //根据运单获取仓库信息
        public  function getBywayId($wayId ){
             $db = $this->getAdapter();
             $filter = $db->quoteInto(' wayId = ?', $wayId);             
             $rows = $this->fetchAll($filter,'id');
            $result = array();
            foreach ($rows as $row)
                    array_push($result,$this->convertRowToObject($row));
            return $result;
        }


        /*
         * 根据用户序号获取信息
         */
        public  function getByUser($userId,$state,$start,$row){
            
            $db = $this->getAdapter();
            $filter = $db->quoteInto(' userId = ?', $userId);    
            if($state!=-1){
            $filter = $db->quoteInto(' status = ?', $state);   }
            $rows = $this->fetchAll($filter,'id',$row,$start);
            
            $result = array();
            foreach ($rows as $row)
                    array_push($result,$this->convertRowToObject($row));
            return $result;
            
        }
        
        /*
         * 根据用户名，状态获取当前总数
         * @param int $userid 用户序号
         * @param int $status 用户序号
		 * @return int
         */
        public  function getItemCount($user,$status){
            
            $db = $this->getAdapter();
            
            if( $status ==-1){
                $result = $db->query('select count(*) from uuch_wayBill where userid='.$user);
            }
            else{
                $result = $db->query('select count(*) from uuch_wayBill where userid='.$user.' and status='.$status );
            }            
            $c = $result->fetchColumn();
            return $c;
        }
        
        
}